package com.xx.sg.controller;

import com.xx.sg.own.entity.User;
import com.xx.sg.own.service.UserService;
import com.xx.sg.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping("/user")
@Tag(name = "人员信息Api", description = "人员信息Api")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/usersByDept")
    @Operation(summary = "查询部门下人员列表", description = "查询部门下人员列表")
    public R usersByDept(String deptId) {
        List<User> list = new ArrayList<>();
        if ("00115".equals(deptId)) {
            list.addAll(userService.selectUsersByDept("01"));
        }

        list.addAll(userService.selectUsersByDept(deptId));
        R r = R.success(list);
        r.put("message", "成功");
        r.put("success", true);
        return r;
    }

    @GetMapping("/usersInfoByDept")
    @Operation(summary = "查询部门下人员列表带值班信息", description = "查询部门下人员列表带值班信息")
    public R usersInfoByDept(String deptId) {
        List<User> users = userService.selectUsersByDeptId(deptId);
        R r = R.success(users);
        r.put("message", "成功");
        r.put("success", true);
        return r;
    }

}
